//
//  BaseTableViewController.m
//  CarCare
//
//  Created by ileo on 14-8-22.
//  Copyright (c) 2014年 baozun. All rights reserved.
//

#import "BaseTableViewController.h"

@interface BaseTableViewController () <LoadMoreControllerDelegate>

@property (nonatomic, strong) LoadMoreView *loadMoreView;

@property (nonatomic, assign) TYPE_TABLE_REFRESH tableRefreshType;

@end

@implementation BaseTableViewController

- (instancetype)init
{
    self = [self initWithTableRefreshType:TYPE_TABLE_REFRESH_NONE];
    if (self) {
    }
    return self;
}

-(id)initWithTableRefreshType:(TYPE_TABLE_REFRESH)type{
    TYPE_MAIN_VIEW mainViewType = (type == TYPE_TABLE_REFRESH_PULL_DOWN || type == TYPE_TABLE_REFRESH_PULL_UP_DOWN)? TYPE_MAIN_VIEW_TABLE_PULLDOWN : TYPE_MAIN_VIEW_TABLE_NORMAL;
    self = [super initWithMainViewType:mainViewType];
    if (self) {
        self.tableRefreshType = type;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (self.tableRefreshType == TYPE_TABLE_REFRESH_PULL_UP ||
        self.tableRefreshType == TYPE_TABLE_REFRESH_PULL_UP_DOWN) {
        self.canPullUp = YES;
        [self setTableViewPullUp];
    }
    
    if ([self.tableView isKindOfClass:[UITableView class]]) {
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
    }
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(UITableView *)tableView{
    return (UITableView *)self.scrollView;
}
-(void)setTableViewPullUp{
    LoadMoreView *bottomView = [[LoadMoreView alloc] initWithFrame:CGRectMake(0, 0, __MAIN_WIDTH, 45)];
    bottomView.tipsLoading = @"加载中";
    bottomView.tipsLoadingDone = @"加载完成";
    bottomView.tipsPulling = @"上拉即将加载";
    bottomView.tipsShouldLoad = @"松手立刻加载";
    bottomView.autoHideTips = YES;
    self.loadMoreController.loadBottomView = bottomView;
}


#pragma mark - tableView
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    return nil;
}


@end
